var r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", t = function(r) {
    r = r.replace(/\r\n/g, "\n");
    for (var t = "", e = 0; e < r.length; e++) {
        var o = r.charCodeAt(e);
        o < 128 ? t += String.fromCharCode(o) : o > 127 && o < 2048 ? (t += String.fromCharCode(o >> 6 | 192), 
        t += String.fromCharCode(63 & o | 128)) : (t += String.fromCharCode(o >> 12 | 224), 
        t += String.fromCharCode(o >> 6 & 63 | 128), t += String.fromCharCode(63 & o | 128));
    }
    return t;
}, e = function(r) {
    for (var t = "", e = 0, o = 0, u = 0, a = 0; e < r.length; ) (o = r.charCodeAt(e)) < 128 ? (t += String.fromCharCode(o), 
    e++) : o > 191 && o < 224 ? (u = r.charCodeAt(e + 1), t += String.fromCharCode((31 & o) << 6 | 63 & u), 
    e += 2) : (u = r.charCodeAt(e + 1), a = r.charCodeAt(e + 2), t += String.fromCharCode((15 & o) << 12 | (63 & u) << 6 | 63 & a), 
    e += 3);
    return t;
};

module.exports = {
    decode: function(t) {
        var o, u, a, n, C, h, d = "", c = 0;
        for (t = t.replace(/[^A-Za-z0-9\+\/\=]/g, ""); c < t.length; ) o = r.indexOf(t.charAt(c++)) << 2 | (n = r.indexOf(t.charAt(c++))) >> 4, 
        u = (15 & n) << 4 | (C = r.indexOf(t.charAt(c++))) >> 2, a = (3 & C) << 6 | (h = r.indexOf(t.charAt(c++))), 
        d += String.fromCharCode(o), 64 != C && (d += String.fromCharCode(u)), 64 != h && (d += String.fromCharCode(a));
        return d = e(d);
    },
    encode: function(e) {
        var o, u, a, n, C, h, d, c = "", f = 0;
        for (e = t(e); f < e.length; ) n = (o = e.charCodeAt(f++)) >> 2, C = (3 & o) << 4 | (u = e.charCodeAt(f++)) >> 4, 
        h = (15 & u) << 2 | (a = e.charCodeAt(f++)) >> 6, d = 63 & a, isNaN(u) ? h = d = 64 : isNaN(a) && (d = 64), 
        c = c + r.charAt(n) + r.charAt(C) + r.charAt(h) + r.charAt(d);
        return c;
    },
    emjoyTest: function(r) {
        return /[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F]|[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF]|[0-9|*|#]\uFE0F\u20E3|[0-9|#]\u[\u203C-\u3299]\uFE0F\u200D|[\u203C-\u3299]\uFE0F|[\u2122-\u2B55]|\u303D|[\A9|\AE]\u3030|\uA9|\uAE|\u3030/gi.test(r);
    }
};